﻿using System.Text.Json;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;

namespace ZeroSum.Extend.Swagger.Filters;

public class CamelCaseNamingOperationFilter : IOperationFilter
{
    public void Apply(OpenApiOperation operation, OperationFilterContext context)
    {
        operation.Parameters?.ToList()?.ForEach(op => { op.Name = JsonNamingPolicy.CamelCase.ConvertName(op.Name); });

        operation.Tags?.ToList()?.ForEach(tag => { tag.Name = tag.Name; });
    }
}